<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<f:view>
    <link href="/evento/css/admin_2.css" rel="stylesheet" type="text/css"/>
    <t:div>

        <h:form>

            <h:panelGrid columns="1" width="100%" styleClass="tablaprincipal">
               <h:outputLabel value="Material Académico" />
            </h:panelGrid>
            <a4j:outputPanel ajaxRendered="true">
                <h:messages id="lblMessages" styleClass="messages" infoClass="infoClass" errorClass="errorClass"
                            warnClass="warnClass" showDetail="true" errorStyle="color:red;"
                            warnStyle="color:green;" infoStyle="color:black;" fatalStyle="color:black"/>
            </a4j:outputPanel>
            <h:panelGrid columns="1" width="100%">
                <h:commandButton styleClass="desactivar"
                                 accesskey="N" id="btnNuevo" value="Nuevo"
                                 action="#{MaterialAcademicoController.ir_a_nuevo}" />
            </h:panelGrid>
            <br/>
            <a4j:outputPanel id="panel1">
                <h:panelGrid columns="2" styleClass="tablanormal">
                    <h:outputLabel value="Curso " />
                    <h:selectOneMenu value="#{MaterialAcademicoController.codigoCurso}">
                        <f:selectItem itemLabel="-- Seleccione un Curso --"/>
                        <f:selectItems value="#{MaterialAcademicoController.comboCursos}" />
                        <a4j:support ajaxSingle="true" action="#{MaterialAcademicoController.listar}" reRender="panel1,panel2" event="onchange"/>
                    </h:selectOneMenu>
                </h:panelGrid>
            </a4j:outputPanel>

            <a4j:outputPanel id="panel2">
                <rich:dataTable value="#{MaterialAcademicoController.listaMaterialAcademico}"
                                var="material" rows="15" reRender="ds" id="simpletable"
                                width="100%" columnsWidth="5%,25%,15%,15%,30%,10%">
                    <f:facet name="header">
                        <rich:columnGroup>
                            <rich:column colspan="6" >
                                <h:outputLabel value=""/>
                            </rich:column>
                            <rich:column breakBefore="true">
                                <h:outputLabel value="Codigo"/>
                            </rich:column>
                            <rich:column>
                                <h:outputLabel value="Curso"/>
                            </rich:column>
                            <rich:column>
                                <h:outputLabel value="Titulo"/>
                            </rich:column>
                            <rich:column>
                                <h:outputLabel value="Tema"/>
                            </rich:column>
                            <rich:column>
                                <h:outputLabel value="Objetivos"/>
                            </rich:column>
                            <rich:column>
                                <h:outputLabel value="Opciones"/>
                            </rich:column>
                        </rich:columnGroup>
                    </f:facet>
                    <rich:column>
                        <h:outputLabel value="#{material.macCodigo}" />
                    </rich:column>
                    <rich:column>
                        <h:outputLabel value="#{material.curCodigo.preevento.preNombre}" />
                    </rich:column>
                    <rich:column>
                        <h:inputTextarea value="#{material.macTitulo}" rows="3" cols="20" disabled="true" />
                    </rich:column>
                    <rich:column>
                        <h:inputTextarea value="#{material.macTema}" rows="3" cols="20" disabled="true" />
                    </rich:column>
                    <rich:column>
                        <h:inputTextarea value="#{material.macObjectivos}" rows="3" cols="25" disabled="true" />
                    </rich:column>
                    <rich:column>
                        <h:commandButton value="Editar" title="Editar" image="/img/editar.png"
                                         action="#{MaterialAcademicoController.ir_a_editar}">
                            <f:setPropertyActionListener target="#{MaterialAcademicoController.materialAcademico}" value="#{material}" />
                        </h:commandButton>
                        &nbsp;&nbsp;
                        <h:commandButton value="Eliminar" title="Eliminar" image="/img/eliminar.png"
                                         action="#{MaterialAcademicoController.eliminar}"
                                         onclick="return confirm('Deseas eliminar el Material Académico?');">
                            <f:setPropertyActionListener target="#{MaterialAcademicoController.materialAcademico}" value="#{material}" />
                        </h:commandButton>
                        &nbsp;&nbsp;
                        <h:commandButton value="Ver" title="Ver Detalle" image="/img/ver.png"
                                         action="#{MaterialAcademicoController.listarDetalleMaterial}">
                            <f:setPropertyActionListener target="#{MaterialAcademicoController.materialAcademico}" value="#{material}" />
                        </h:commandButton>
                    </rich:column>
                    <f:facet name="footer">
                        <rich:datascroller id="ds" renderIfSinglePage="false"></rich:datascroller>
                    </f:facet>
                </rich:dataTable>

                <br/>

                <rich:dataTable value="#{MaterialAcademicoController.listaDetalleMaterial}"
                            var="detalle" rows="15" reRender="ds" id="simpletable2"
                            width="100%" columnsWidth="5%,85%,10%">
                <f:facet name="header">
                    <rich:columnGroup>
                        <rich:column colspan="3" >
                            <h:outputLabel value=""/>
                        </rich:column>
                        <rich:column breakBefore="true">
                            <h:outputLabel value="Codigo"/>
                        </rich:column>
                        <rich:column>
                            <h:outputLabel value="Contenido"/>
                        </rich:column>
                        <rich:column>
                            <h:outputLabel value="Opciones"/>
                        </rich:column>
                    </rich:columnGroup>
                </f:facet>
                <rich:column>
                    <h:outputLabel value="#{detalle.dmaCodigo}"/>
                </rich:column>
                <rich:column>
                    <h:inputTextarea value="#{detalle.dmaContenido}" rows="2" cols="80" disabled="true" />
                </rich:column>
                <rich:column>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <h:commandButton value="Eliminar" title="Eliminar" image="/img/eliminar.png"
                                     action="#{MaterialAcademicoController.eliminarDetalle}"
                                     onclick="return confirm('Deseas eliminar el Detalle Material?');">
                        <f:setPropertyActionListener target="#{MaterialAcademicoController.detalleMaterial}" value="#{detalle}" />
                    </h:commandButton>
                </rich:column>
                <f:facet name="footer">
                    <rich:datascroller id="ds" renderIfSinglePage="false"></rich:datascroller>
                </f:facet>
            </rich:dataTable>

            </a4j:outputPanel>
        
        
    </h:form>
</t:div>
<%--@include file="../jspf/pie.jspf" --%>
</f:view>
